<template>
  <div class="teachers-container">
    <div class="teacher-card" v-for="teacher in teacherList" :key="teacher.id">
      <p class="college-p">{{ teacher.college.college }}</p>
      <div class="card-body-flex">
        <img :src="teacher.image" alt="教师照片" class="teacher-image">
        <div class="teacher-info-wrap">
          <div class="teacher-info">
            <h2 class="teacher-name">{{ teacher.name }}</h2>
            <p class="teacher-title">{{ teacher.position }}</p>
          </div>
          <p class="teacher-description">{{ teacher.introduce }}</p>
          <div class="teacher-skills">
            <span v-for="(skill, index) in teacher.skill.split(' ')" :key="index" class="skill-tag">
              {{ skill }}
            </span>
          </div>
        </div>
      </div>
    </div>
  </div>  
</template>

<script setup>
import http from '@/http';
import { ref, onMounted } from 'vue';

const teacherList = ref([]);
onMounted(() => {
  http({
    method: 'get',
    url: 'cont/famous/'

  }).then(resp => {
    teacherList.value.splice(0, teacherList.length, ...resp.data.data)
    console.log(resp);

  }).catch(error => {
    console.log(error);

  })
})
</script>

<style scoped>
.teachers-container {
  width: 800px;
  margin: 0 auto;
}

.college-p {
  margin: 10px 0 0 20px;
  font-size: 14px;
  color: #666;
}

.teacher-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  margin: 20px 0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.3s ease;
}

.teacher-card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.card-body-flex {
  display: flex;
  padding: 20px;
}

.teacher-image {
  width: 160px;
  height: 280px;
  object-fit: cover;
  border-radius: 4px;
  margin-right: 20px;
}

.teacher-info-wrap {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
}

.teacher-info {
  margin-bottom: 10px;
}

.teacher-name {
  font-size: 22px;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 4px;
}

.teacher-title {
  font-size: 16px;
  color: #4b5563;
  margin: 0;
}

.teacher-description {
  font-size: 14px;
  line-height: 1.6;
  color: #374151;
  margin: 0 0 10px;
}

.teacher-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skill-tag {
  padding: 4px 12px;
  background-color: #f3f4f6;
  color: #4b5563;
  border-radius: 4px;
  font-size: 14px;
  transition: background-color 0.3s ease;
}

.skill-tag:hover {
  background-color: #e5e7eb;
}
</style>